<?php
/**
 * Framework class autoloader
*/
class Loader
{
   /**
     * autoloader
     * @param $class classname
     */
    static function autoload($class)
    {
        $folders = array('application/library/framework/core' ,
                         'application/library/framework/database',
                         'application/library/framework/util',
                         'application/library/framework/plugin',
                         'application/model',
                         'application/widget',
                         'application/view',
                         'application/controller');
                         
        // search in appp root
        if (file_exists("{$class}.class.php"))
        {
            include_once "{$class}.class.php";
            return;
        }
       
        foreach ($folders as $folder)
        {
            if (file_exists("{$folder}/{$class}.class.php"))
            {
                include_once "{$folder}/{$class}.class.php";
                return;
            }
            if (file_exists("{$folder}/{$class}.php"))
            {
                include_once "{$folder}/{$class}.php";
                return;
            }
            
        }
    }
}
?>